const comment = {
  prefix: "/comment",

  /**
   * 根据文章id和用户id获取评论列表 文章id优先级更高
   * @param {Integer} aid 文章id
   * @param {Integer} uid 用户id
   * @param {Integer} page 页数
   * @param {Integer} size 每页大小
   * @returns
   */
  getCommentList(aid = null, uid = null, page = 1, size = 10) {
    let params = {
      page: page,
      size: size,
    };
    if (aid) {
      params.aid = aid;
    }
    if (uid) {
      params.uid = uid;
    }
    return {
      url: `${this.prefix}`,
      params: params,
    };
  },

  getReplyList(cid = null, uid = null, page = 1, size = 4) {
    let params = {
      page: page,
      size: size,
    };
    if (cid) {
      params.cid = cid;
    }
    if (uid) {
      params.uid = uid;
    }
    return {
      url: `${this.prefix}/reply`,
      params: params,
    };
  },

  /**
   * 给评论点赞
   * @param {Integer} id 评论id
   * @returns {import("axios").AxiosRequestConfig}
   */
  thumbsUp(id) {
    return {
      url: `${this.prefix}/up/${id}`,
    };
  },

  /**
   * 给回复点赞
   * @param {Integer} id 回复评论id
   * @returns {import("axios").AxiosRequestConfig}
   */
  thumbsUpReply(id) {
    return {
      url: `${this.prefix}/reply/up/${id}`,
    };
  },

  /**
   * 添加评论
   * @param {Comment} comment
   * @returns
   */
  addComment(comment) {
    return {
      method: "post",
      url: `${this.prefix}`,
      data: comment,
    };
  },

  /**
   * 添加回复
   * @param {Reply} reply
   * @returns
   */
  addReply(reply) {
    return {
      method: "post",
      url: `${this.prefix}/reply`,
      data: reply,
    };
  },

  getMaxId() {
    return {
      url: `${this.prefix}/max`,
    };
  },

  getReplyMaxId() {
    return {
      url: `${this.prefix}/reply/max`,
    };
  },
};

export default comment;
